// 两个队列实现栈
var MyStack = function() {
    this.stack1 = [];
    this.stack2 = [];
};

/** 
 * @param {number} x
 * @return {void}
 */
MyStack.prototype.push = function(x) {
    this.stack1.push(x);
};

/**
 * @return {number}
 */
MyStack.prototype.pop = function() {
    while(this.stack1.length>1) {
        this.stack2.push(this.stack1.shift())
    }
    let ans = this.stack1.shift();
    while(this.stack2.length) {
        this.stack1.push(this.stack2.shift())
    }
    return ans;
};

/**
 * @return {number}
 */
MyStack.prototype.top = function() {
    return this.stack1.slice(-1)[0]
};

/**
 * @return {boolean}
 */
MyStack.prototype.empty = function() {
    return !this.stack1.length
};
